package com.zee.wechat.framework.vo;

import com.zee.wechat.framework.enums.ResultCode;
import com.zee.wechat.framework.enums.StatusCode;
import lombok.Data;

/**
 * 统一数据返回对像
 *
 * @author Zee
 * @date 2020年6月10日
 */
@Data
public class ResponseResult {
    /**
     * 状态码
     */
    private String code;
    /**
     * 状态信息
     */

    private String msg;

    /**
     * 返回对象
     */

    private Object data;

    /**
     * 手动设置返回vo
     *
     * @param code
     * @param msg
     * @param data
     */
    public ResponseResult(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 默认返回成功状态码，数据对象
     *
     * @param data
     */
    public ResponseResult(Object data) {
        this.code = ResultCode.SUCCESS.getCode();
        this.msg = ResultCode.SUCCESS.getMsg();
        this.data = data;
    }

    public ResponseResult(String code, String msg) {
        this.code = code;
        this.msg = msg;

    }

    /**
     * 返回指定状态码，数据对象
     *
     * @param statusCode
     * @param data
     */
    public ResponseResult(StatusCode statusCode, Object data) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
        this.data = data;
    }

    /**
     * 只返回状态码
     *
     * @param statusCode
     */
    public ResponseResult(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
        this.data = null;
    }
}
